<script type="text/javascript">	
  	function doDelete() {		
  		answer = confirm("Bạn chắc chắn muốn xóa quảng cáo này?");		
  		if(answer) {			
  			document.getElementById('frm_delete').submit();		
  		}	
  	}
 </script> 
 <form action = '<?php echo base_url();?>index.php/advertisement/get_by_fillter' method = 'post'>
	<table style="margin-left: 50px">
		<tr>
			<td width="180">Hoạt động</td>
			<td>Loại</td>
		</tr>
		<tr>
			<td>
				<select name = 'status'>
					<option value = 'default'>Toàn bộ</option>
					<option value = 'Có'>Có</option>
					<option value = 'Không'>Không</option>
				</select>
			</td>
			<td>
				<select name = 'type'>
					<option value = 'default'>Toàn bộ</option>
					<option value = 'banner'>Banner</option>
					<option value = 'micro'>Micro</option>
				</select>
			</td>
			<td><input type = 'submit' name = 'submit' value = 'Tìm kiếm'></td>
		</tr>
	</table>
 </form>
<div style="height: 38px; border-bottom: 1px solid grey; margin-bottom: 20px; padding-right: 30px; ">
	<a onclick = "doDelete()" href="#" style="float: right">
		<img src="<?php echo base_url()?>template/backend/images/btn_delete.png" border="0" />
	</a>
	<a href="<?php echo base_url()?>index.php/advertisement/add"  style="float: right; margin-right: 20px">
		<img src="<?php echo base_url()?>template/backend/images/btn_add.png" border="0" />
	</a>
	<div class="clear: right"></div>
</div>

<form action="<?php echo base_url().'index.php/advertisement/delete'?>" method="post" enctype="multipart/form-data" id="frm_delete">
<table class="list" width="100%" cellpadding="5" >
	<tr style="color: #fff; font-weight: bold" bgcolor="#ad2f33" >
		<td align="center">
			<input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" />
		</td>
		<td>Tên</td>
		<td>Vị trí</td>
		<td>Loại</td>
		<td>Banner</td>
		<td>Mô tả</td>
		<td>Trạng thái</td>
		<td>Thao tác</td>
	</tr>
	<?php if ($list) { ?>
    <?php $class = 'odd_row_style'; ?>
    <?php foreach ($list as $item) { ?>
    <?php $class = ($class == 'even_row_style' ? 'odd_row_style' : 'even_row_style'); ?>
      
      <tr class="<?php echo $class; ?>">
		<td align="center"><input type="checkbox" name="selected[]" value="<?php echo $item['id']; ?>" /> </td>
    	<td align="center">
    		<a href="<?php echo base_url().'index.php/advertisement/update/'. $item['id'] ;?>">
    			<?php echo $item['name']?>
    		</a>
    	</td>
    	<td>
        	<?php echo '<p>'. $item['position'] . '</p>';  ?>
        </td>
    	<td>
        	<?php echo '<p>'. $item['type'] . '</p>';  ?>
        </td>
		<?php
			if($item['type'] == 'banner'){
				echo '<td><img src = "'.base_url().$item['image'].'"></td>';
			}
			else
			{
				echo '<td></td>';
			}
		?>
    	<td>
        	<?php echo '<p>'. $item['description'] . '</p>';  ?>
        </td>
    	<td>
        	<?php echo '<p>'. $item['status'] . '</p>';  ?>
        </td>
    	<td align="center">
    		<a href="<?php echo base_url().'index.php/advertisement/update/'.$item['id']?>">Sửa</a>
    	</td>
    </tr>
    <?php } ?>
	<?php } ?>
	
</table>
</form>